Ext.BLANK_IMAGE_URL = "../../web/ext/images/default/s.gif";

Ext.onReady(function(){
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	
	var flds = [];
	var cols = window._data.columns;
	for (var i = 0; i < cols.length; ++i) {
		flds[i] = {name: "col"+i};
		if (cols[i].type)
		  flds[i].type = cols[i].type;
		cols[i].dataIndex = "col"+i;
	}
	
	var grid = new Ext.grid.GridPanel({
	    store: new Ext.data.SimpleStore({
	      fields: flds,
	      data: window._data.content
	    }),
	    columns: cols,
	    stripeRows: true,
	    title: window._data.title
	});
	
	grid.render('mapGrid');
	
	grid.getSelectionModel().selectFirstRow();
});

function renderLink(val) {
	if (val == "|")
	  return "";
	var i = val.indexOf("|");
	var uri = val;
	if (i > 0) {
	  uri = val.substring(0, i);
	  val = val.substring(i+1);
	  if (val == "")
	    val = uri;
	}
	if (val.length > 43)
		val = val.substring(0, 42) + "...";
	return "<a href='"+uri+"'>"+val+"</a>";
}
